package indi.lqzhi.basic;

import android.app.Application;
import android.graphics.Typeface;

import indi.lqzhi.basic.tools.thirdparty.MMKVTools;


public abstract class BasicApp extends Application {

    /**
     * Application单例
     */
    private static volatile BasicApp basicApp;
    /**
     * 是否开启debug
     */
    private static boolean isDebug = false;

    @Override
    public void onCreate() {
        super.onCreate();
        basicApp = this;//设置单例
        iniApplication();
        MMKVTools.initMMKV(this,isDebug());
    }

    /**
     * 打开Debug
     */
    public void openDebug(){
        isDebug = true;
    }

    /**
     * 关闭Debug
     */
    public void closeDebug(){
        isDebug = false;
    }

    /**
     * 初始化数据，由闪屏页调用
     */
    public abstract void iniApplication();

    /**
     * 获取Application单例
     * @return Application单例
     */
    public static <T extends BasicApp> T getApp() {
        return (T) basicApp;
    }

    /**
     * 是否开启debug
     * @return true 实现了LogAction接口的能够正常工作 false 不打印任何日志
     */
    public static boolean isDebug() {
        return isDebug;
    }

}
